{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3052
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var
	n,i:longint;
	t:array[0..10] of longint;
 
procedure go(tp,k:longint);
begin
if tp=1 then begin
	if k=1 then begin
		if t[1]=1 then writeln('1 1 2');
		writeln('1 2 3');
	end else begin
		if t[k]=1 then begin
			go(1,k-1);
			writeln(k,' 1 2');
			go(-1,k-1);
			writeln(k,' 2 3');
			go(1,k-1);
		end else 
		if t[k]=2 then begin
			go(-1,k-1);
			writeln(k,' 2 3');
			go(1,k-1);
		end;
	end;
	t[k]:=3;
end else 
if tp=2 then begin
	if k=1 then begin
		if t[1]=3 then writeln('1 3 1');
		writeln('1 1 2');
	end else begin
		if t[k]=1 then begin
			go(1,k-1);
			writeln(k,' 1 2');
			go(2,k-1);
		end else
		if t[k]=3 then begin
			go(-1,k);
			go(2,k);
		end;
	end;
	t[k]:=2;
end else begin
	if k=1 then begin
		if t[1]=2 then writeln('1 2 3');
		writeln('1 3 1');
	end else begin
		if t[k]=3 then begin
			go(-1,k-1);
			go(2,k-1);
			writeln(k,' 3 1');
			go(1,k-1);
			go(-1,k-1);
		end else
		if t[k]=2 then begin
			go(1,k);
			go(-1,k);
		end;
	end;
	t[k]:=1;
end;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=1 to n do
	t[i]:=1;
go(1,n);
end.